package com.yzp.service;

import com.yzp.entity.master.Student;
import com.yzp.master.dao.StudentDao;
import com.yzp.entity.slave.Teacher;
import com.yzp.slave.dao.TeacherDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Description
 *
 * @className: CurdService
 * @author: yanzhouping
 * @date: 2019/9/18 10:48
 */
@Service
public class CurdService {

    @Autowired
    private StudentDao studentDao;

    @Autowired
    private TeacherDao teacherDao;

    @Transactional(rollbackFor = Exception.class)
    public void add(int code) {
        Student s1 = new Student();
        s1.setAge(10);
        s1.setGrade(10);
        s1.setName("s1");
        studentDao.save(s1);
        int result = 1/code;
        Teacher t1 = new Teacher();
        t1.setAge(10);
        t1.setName("t1");
        t1.setCourse(10);
        teacherDao.save(t1);


    }
}
